package cn.yunyichina.provider.iface.entity.common;

import java.io.Serializable;

/**
 * 2016-08-23
 *
 * @author zhangkewen
 */
public class ResponseObject implements Serializable {

    private String resultCode = "0";

    private String resultMessage = "success";

    private String time;

    private Object resultObject;

    public ResponseObject() {

    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getResultCode() {
        return resultCode;
    }

    public String getResultMessage() {
        return resultMessage;
    }

    public Object getResultObject() {
        return resultObject;
    }

    public void setResultObject(Object resultObject) {
        this.resultObject = resultObject;
    }

    public ResponseObject(String resultCode, String resultMessage) {
        super();
        this.resultCode = resultCode;
        this.resultMessage = resultMessage;
    }

    public ResponseObject(String resultCode, String resultMessage, Object resultObject) {
        super();
        this.resultCode = resultCode;
        this.resultMessage = resultMessage;
        this.resultObject = resultObject;
    }

    public ResponseObject buildResultObject(Object resultObject) {
        this.resultObject = resultObject;
        return this;
    }

    public void setResultCodeAndMessage(String resultCode, String resultMessage) {
        this.resultCode = resultCode;
        this.resultMessage = resultMessage;
    }

    public ResponseObject buildResultCodeAndMessage(String resultCode, String resultMessage) {
        this.resultCode = resultCode;
        this.resultMessage = resultMessage;
        return this;
    }

    public void setResultCodeAndMessageAndResult(String resultCode, String resultMessage, Object resultObject) {
        this.resultCode = resultCode;
        this.resultMessage = resultMessage;
        this.resultObject = resultObject;
    }

    public ResponseObject buildResultCodeAndMessageAndResult(String resultCode, String resultMessage, Object resultObject) {
        this.resultCode = resultCode;
        this.resultMessage = resultMessage;
        this.resultObject = resultObject;
        return this;
    }

    public boolean isSuccess() {
        return "0".equals(resultCode);
    }

    public void fail() {
        resultCode = "-1";
        resultMessage = "failure";
    }

}
